Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UnixAdapter to accept max_retries parameter #42

Merged
merged 1 commit into from
Aug 16, 2019
Merged

Conversation

msabramo
Copy link
Owner

@msabramo msabramo commented Aug 16, 2019

e.g.:

from requests.packages.urllib3.util.retry import Retry
import requests_unixsocket

sess = requests_unixsocket.Session()

HTTP_REQUEST_RETRIES = 3
HTTP_RETRY_BACKOFF_FACTOR = 0.3
HTTP_RETRY_FORCELIST = (404, 500, 502, 504)

retry = Retry(total=HTTP_REQUEST_RETRIES,
              read=HTTP_REQUEST_RETRIES,
              connect=HTTP_REQUEST_RETRIES,
              backoff_factor=HTTP_RETRY_BACKOFF_FACTOR,
              status_forcelist=HTTP_RETRY_FORCELIST)

adapter = requests_unixsocket.UnixAdapter(max_retries=retry)
sess.mount('http+unix://', adapter)

print(sess.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/this-does-not-exist'))

Fixes: GH-37

Cc: @fantamiracle, @keith-bennett-gbg

e.g.:

```python
from requests.packages.urllib3.util.retry import Retry
import requests_unixsocket

sess = requests_unixsocket.Session()

HTTP_REQUEST_RETRIES = 3
HTTP_RETRY_BACKOFF_FACTOR = 0.3
HTTP_RETRY_FORCELIST = (404, 500, 502, 504)

retry = Retry(total=HTTP_REQUEST_RETRIES,
              read=HTTP_REQUEST_RETRIES,
              connect=HTTP_REQUEST_RETRIES,
              backoff_factor=HTTP_RETRY_BACKOFF_FACTOR,
              status_forcelist=HTTP_RETRY_FORCELIST)

adapter = requests_unixsocket.UnixAdapter(max_retries=retry)
sess.mount('http+unix://', adapter)

print(sess.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/this-does-not-exist'))
```

Fixes: GH-37
@msabramo msabramo mentioned this pull request Aug 16, 2019
@keith-bennett-gbg
Copy link

Thank you!

@msabramo msabramo merged commit 5d83b0f into master Aug 16, 2019
@msabramo msabramo deleted the allow-retries branch August 16, 2019 19:05
@msabramo
Copy link
Owner Author

(finally) released in https://pypi.org/project/requests-unixsocket/0.3.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mounting retry adapter
2 participants